package com.aisile.admin.controller;

import com.aisile.admin.service.AdChannelService;

import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("Admin")
public class AdChannelController implements AdminController {
    @Autowired
    AdChannelService adChannelService;
    //查询分页
    @PostMapping("pageAdmin")
    @Override
    public ResponseResult getPageList(@RequestBody ChannelDto dto) {
        return adChannelService.getPageList(dto);
    }
    //添加方法
    @PostMapping("addAdmin")
    @Override
    public ResponseResult addAdmin(@RequestBody AdChannel dto) {
        return adChannelService.addAdmin(dto);
    }

    /**
     * 有效 固定传参为1  1就是有效
     * @param id
     * @return
     */
    @PutMapping("uadminyestatus/{id}")
    @Override
    public ResponseResult updateyesStatus(@PathVariable int id) {
        return adChannelService.updatestatus(id,true);
    }
    /**
     * 无效 固定传参为0  0就是无效
     * @param id
     * @return
     */
    @PutMapping("uadminnotatus/{id}")
    @Override
    public ResponseResult updatenoStatus(@PathVariable int id) {
        return adChannelService.updatestatus(id,false);
    }

    /**
     * 修改方法
     * @param id 前端传过来的id 去数据库中匹配找到该 内容
     * @param dto 存储修改的数据  将前端传过来的数据进行修改
     * @return
     */
    @PutMapping("updateAdmin/{id}")
    @Override
    public ResponseResult updateAdmin(@PathVariable int id,@RequestBody AdChannel dto) {
        return adChannelService.updateAdmin(id,dto);
    }

    /**
     * 根据id拆查询 数据库中的内容
     * @param id
     * @return
     */
    @GetMapping("getlist/{id}")
    @Override
    public ResponseResult getlist(@PathVariable Integer id) {
        return adChannelService.getlist(id);
    }
}
